package cn.tedu.ivos2.application.controller;

import cn.tedu.ivos2.application.pojo.dto.ApplicationQuery;
import cn.tedu.ivos2.application.pojo.dto.ApplicationSaveParam;
import cn.tedu.ivos2.application.pojo.vo.ApplicationVO;
import cn.tedu.ivos2.application.service.ApplicationService;
import cn.tedu.ivos2.base.response.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/v1/application")
public class ApplicationController {
    private ApplicationService applicationService;
    @Autowired
    public void setApplicationService(ApplicationService applicationService) {
        this.applicationService = applicationService;
    }
    @GetMapping("list")
    public JsonResult query(ApplicationQuery query) {
        List<ApplicationVO> list = applicationService.query(query);
        return JsonResult.ok(list);
    }
    @PostMapping("add")
    public JsonResult add(ApplicationSaveParam applicationSaveParam) {
        applicationService.add(applicationSaveParam);
        return JsonResult.ok();
    }
    @PostMapping("cancel/{id}")
    public JsonResult cancel(@PathVariable Long id) {
        applicationService.cancel(id);
        return JsonResult.ok();
    }

}
